package com.zat.mes.andrmes.dofun


import android.content.Intent
import android.view.View
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.zat.mes.andrmes.R
import com.zat.mes.andrmes.base.BaseActivity
import com.zat.mes.andrmes.data.DayPlanNotifBean
import com.zat.mes.andrmes.data.Item
import com.zat.mes.andrmes.dofun.main.MessageNotifActivity
import com.zat.mes.andrmes.dofun.main.adapter.MsgAdapter
import com.zat.mes.andrmes.dofun.main.adapter.NotifiAdapter
import com.zat.mes.andrmes.global.CompanionType
import kotlinx.android.synthetic.main.activity_msslist.*
import kotlinx.android.synthetic.main.activity_notification.*
import kotlinx.android.synthetic.main.layout_title.*

class MessageListActivity : BaseActivity() {

    override fun init() {
        initView()
        initData()
    }

    private fun initData() {
        val parcelableArrayListExtra =
            intent.getParcelableArrayListExtra<Item>("msgList")
        val msgAdapter = MsgAdapter(R.layout.item_msg_list)
        rvMsgList.layoutManager = LinearLayoutManager(this)
        rvMsgList.addItemDecoration(DividerItemDecoration(this,DividerItemDecoration.VERTICAL))
        rvMsgList.adapter = msgAdapter
        msgAdapter.setNewData(parcelableArrayListExtra)
        msgAdapter.setOnItemClickListener { adapter, view, position ->
            val intent = Intent(this, MessageNotifActivity::class.java)
            intent.putExtra(CompanionType.INTENT_EXTRA_BEAN,msgAdapter.getItem(position) )
            startActivity(intent)
        }
    }

    private fun initView() {
        setContentView(R.layout.activity_msslist)
        tVtitle.text = "公告列表"
        rlReturnTitle.visibility = View.VISIBLE
        rlReturnTitle.setOnClickListener { finish() }
    }

}